/**
 * 案例：（影子依赖）依赖缺失的技术方案
 */
const fs = require('fs');
const path = require('path');
const acorn = require('acorn');
// 读取源文件
const srcFilePath = path.join(__dirname, './src/shadow.js');
const srcFileContent = fs.readFileSync(srcFilePath, 'utf-8');
const originAST = acorn.parse(srcFileContent, {
    ecmaVersion: 'latest',
    sourceType: 'module',
}).body;
// 读取所有 import 的语句
const allImportNode = originAST.filter((n) => n.type === 'ImportDeclaration');
const allImportName = allImportNode.map((n) => n.source.value);
// 读取package.json 的依赖
const packageJsonPath = path.join(__dirname, './package.json');
let { dependencies } = require(packageJsonPath);
dependencies = Object.keys(dependencies);

console.log('dependencies', dependencies);
console.log('allImportName', allImportName);




